home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
050
/
tptool.lbr
/
OS-CPM86.PQS
/
os-cpm86.pas
Wrap
Pascal/Delphi Source File
|
1985-06-03
|
3KB
|
94 lines
{ OS-CPM86.PAS }
{ put all CP/M-86 specific code in this file }
{ THIS CP/M-86 VERSION DOES NOT WORK PROPERLY, AND IS DISABLED }
{ PROBLEM SEEMS TO BE IN SETTING THE DMA TO THE VARIABLE "dmabuf" - wk }
procedure listcat;
{ List file names on standard output; pasted together from OS-CPM80 and
OS-MSDOS by W. Kempton. }
{ version: January 1985 }
const
maxfiles = 256;
SearchFirst = 17;
SearchNext = 18;
var
i,j,k: integer;
dmabuf: array [1..130] of byte;
DirBuf: array[1..maxfiles] of packed array [0..11] of char;
fcb : array[0..36] of byte;
name : XSTRING ;
kDB : integer;
Regs :
record
AX, BX, CX, DX, BP, SI, DI, DS, ES, Flags : Integer;
end;
Function Search(NameCount: integer): integer;
begin
if NameCount = 0
then Regs.CX := SearchFirst
else Regs.CX := SearchNext;
Regs.DX := ofs(fcb);
Regs.DS := Seg(fcb);
Bdos(Regs);
Search := Regs.AX and $FF ;
end { Search };
procedure SetDMA(Segment, Offset: integer);
begin
Regs.CX := $001A;
Regs.DS := Segment;
Regs.DX := Offset;
Bdos(Regs);
end;
begin
if TRUE { set FALSE to test this module }
then writeln('list: not yet implemented on CP/M-86')
else
begin
fcb[0] := 0; { set up file control block }
for i:=1 to 11 do fcb[i]:= ord('?');
for i:= 12 to 36 do fcb[i] := 0;
for i:= 1 to 130 do dmabuf[i] := 0;
SetDma(Seg(dmabuf),Ofs(dmabuf) ); { DMA set to local variable }
i := 0;
j := Search(i);
while (j < 255) and (i < maxfiles) do
begin
i := i + 1;
move (dmabuf[j*32 +1], DirBuf[i], 12); { save name }
j := Search(i); { search for next }
end;
{ SetDma( ????, $80);} { restore DMA address }
for j := 1 to i do { write names to STDOUT }
begin
k := 1;
while (k<9) and (DirBuf[j,k]<>' ') do
begin
name[k]:=ord(DirBuf[j,k]); k:=k+1;
end;
if DirBuf[j,9] <> ' ' then
begin { read from kDB, write to k }
kDB := 9;
name[k] := ord('.'); k := k+1;
repeat
name[k] := ord(DirBuf[j,kDB]); k := k+1; kDB:=kDB+1;
until (kDB=12) or (DirBuf[j,kDB] = ' ');
end;
for i := 1 to (k-1) do
name[i] := name[i] mod 128; { clear attribute bits }
name[k] := ENDSTR;
PUTSTR(name,STDOUT);PUTC(NEWLINE); { use K&R, not WRITE/WRITELN }
end;
end;
end;